package cc.atliberty.structural.composite.ex3;

import java.util.ArrayList;

/**
 * @Author 元宵
 * @url www.atliberty.cc
 * @Date 2023-10-31 09:04
 * @description:
 */
public class DirectNode extends Node{
    private ArrayList<Node> nodeList = new ArrayList<>();
    
    public DirectNode(String name) {
        super(name);
    }
    
    public void addNode(Node node) {
        nodeList.add(node);
    }

    @Override
    void display() {
        System.out.println(name);
        for (int i = 0; i < nodeList.size(); i++) {
            nodeList.get(i).display();
        }
    }
}
